package com.baosight.sczx.zm.ca.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.ef.chart.ChartUtils;
import com.baosight.iplat4j.ef.chart.EfChart;
import com.baosight.iplat4j.ef.chart.chartElement.CEApply;
import com.baosight.iplat4j.ef.chart.chartElement.CECategory;
import com.baosight.iplat4j.ef.chart.chartElement.CEDataSeries;
import com.baosight.iplat4j.ef.chart.chartElement.CETrendLine;
import com.baosight.iplat4j.ef.chart.chartElement.CEVLine;
import com.baosight.iplat4j.ef.chart.chartElement.styleImpl.SAnimation;
import com.baosight.iplat4j.ef.chart.chartElement.styleImpl.SFont;
import com.baosight.iplat4j.ef.chart.service.ServiceChartBase;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.Utils;
import com.baosight.sczx.zm.ca.domain.ZMCA4101;

public class ServiceZMCAA05 extends ServiceChartBase{
	/**
	 * 初始化
	 */
	public String[] genInitChartInfo(EiInfo info){
		StringBuffer sb = new StringBuffer();
		sb.append(ChartUtils.chartAttr2Str("bgcolor",info.getString("bgcolor")));
		sb.append(ChartUtils.chartAttr2Str("canvasBgColor",info.getString("canvasBgColor")));
		sb.append(ChartUtils.chartAttr2Str("showValues",info.getString("showValues")));
		
	    return new String[]{"年计划实际对比","月份","销售量",null,null,null,null,sb.toString()};
	}
	
	/**
	 * category
	 */
	public List genChartCatLabels(EiInfo info){
		List list = new ArrayList();

		list.add("一月");
		list.add("二月");
		list.add("三月");
		list.add("四月");
		list.add("五月");
		list.add("六月");
		list.add("七月");
		list.add("八月");
		list.add("九月");
		list.add("十月");
		list.add("十一月");
		list.add("十二月");

		return list;
	}
			
	public void setChartStyle(EiInfo info, EfChart chart){
		if(!"1".equals(info.getString("dataType"))){
			//样式--定义
			SAnimation animation = new SAnimation("Anim1");
			animation.setParam("_yScale");
			animation.setStart("0");
			animation.setDuration("1");
			chart.addStyleDefinition(animation);
			
			SAnimation animation2 = new SAnimation("Anim2");
			animation2.setParam("_alpha");
			animation2.setStart("0");
			animation2.setDuration("5");
			animation2.setEasing("strong");
			chart.addStyleDefinition(animation2);
			
			//设置ShowValues背景及显示字体颜色
			SFont font = new SFont("font1");
			font.setBorderColor("1D8BD1");
			font.setBgColor("1D8BD1");
			font.setColor("FFFFFF");
			chart.addStyleDefinition(font);
			//样式--应用
			chart.addStyleApply(new CEApply(animation,"VLINES"));
			chart.addStyleApply(animation2,"TRENDLINES");
			chart.addStyleApply(font,"DATAVALUES");
		}
	}
	
	protected boolean isMData(EiInfo info){
		if(!"1".equals(info.getString("dataType"))){
			return true;
		}
		return false;
	}
	
	protected List genSeriesNames(EiInfo info){

		List list = new ArrayList();
		list.add("实际");
		list.add("计划");
		return list;
	}
	
	protected List genMChartDataValues(EiInfo info){
		List list = new ArrayList();
		
		List list1 = new ArrayList();
		list1.add("300");
		list1.add("330");
		list1.add("300");
		list1.add("400");
		list1.add("400");
		list1.add("350");
		list1.add("300");
		list1.add("400");
		list1.add("350");
		list1.add("300");
		list1.add("300");
		list1.add("300");
		list.add(list1);
		
		List list2 = new ArrayList();
		list2.add("290");
		list2.add("312");
		list2.add("311");
		list2.add("380");
		list2.add("400");
		list2.add("355");
		list2.add("296");
		list2.add("410");
		list2.add("320");
		list2.add("300");
		list2.add("300");
		list2.add("330");
		list.add(list2);
		
		
		return list;
	}

	/**
	 * 设置对应柱状显示颜色
	 * @return
	 */	
	protected List genMChartDatasetList(EiInfo info){
		String chartType = info.getString("chartType");
		List list = super.genMChartDatasetList(info);
		
		CEDataSeries datasetSeries1 = (CEDataSeries)list.get(0);
		datasetSeries1.setColor("FF9900");
		datasetSeries1.setShowValues("1");
		
		CEDataSeries datasetSeries2 = (CEDataSeries)list.get(1);
		datasetSeries2.setColor("FFFF00");
		datasetSeries2.setShowValues("1");
		
		return list;
	}
}
